home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / common / build next >
Text File  |  1994-10-02  |  5KB  |  172 lines

  1. #!/usr/local/bin/perl
  2. #
  3. #       Copyright (C) Ready-to-Run Software, Inc. 1991, 1992, 1993.
  4. #       Groton, MA 01450.
  5. #
  6. #       All Rights Reserved.
  7. #
  8. #    This Module contains Proprietary Information of 
  9. #       Ready-to-Run Software, Inc. 
  10. #
  11. #       Ready-to-Run Software, Inc. is a software service company.  Most
  12. #       of the software provided to our customers is "publically
  13. #       available"; we provide the service of locating and building
  14. #       the software for you.  In general, you may make as many copies
  15. #       as you want of the software that we deliver to you (individual
  16. #       package license information is provided during the installation
  17. #       process). The major exception to that is Ready-to-Run Software's 
  18. #       "Smart Installation System".  We view the installation system
  19. #       and the proprietary techniques used in it, as the vehicle that
  20. #       allows us to effectively deliver our services to you.  Accordingly:
  21. #
  22. #              Use of this "Smart Installation System" is limited as follows:
  23. #
  24. #       1) by anyone, to install a SAMPLE ReadyPak(tm) from 
  25. #          Ready-to-Run Software, Inc.
  26. #       2) by a ReadyPak Purchaser to install a ReadyPak obtained from
  27. #          Ready-to-Run Software, Inc. on any machine within your
  28. #          organization.  
  29. #       3) It may not be copied or otherwise distributed without written
  30. #          permission from Ready-to-Run Software, Inc.
  31. #
  32. # $Id: build,v 1.2 1993/01/16 14:05:15 jeff Exp jeff $
  33. #
  34. # $Log: build,v $
  35. # Revision 1.2  1993/01/16  14:05:15  jeff
  36. # Actual release version
  37. #
  38. # Revision 1.1  1992/12/18  02:34:10  jeff
  39. # Initial revision
  40. #
  41. #
  42. $0 =~ m|(.*/)(.*)|, $PROG = $2; $EXECDIR = $1; # find program name
  43.  
  44. # set up some necessary constants and defaults
  45. $TRUE  = 1;
  46. $FALSE = 0;
  47. $SYMLINK_EXISTS = (eval 'symlink("","");', $@ eq '' );
  48.  
  49. $MACHINE = shift @ARGV;
  50. $CDROM = shift @ARGV;
  51. $SourcePak = $TRUE;
  52.  
  53. $[ = 0;            # set array base to 0
  54. $, = ' ';        # set output field separator
  55. $\ = "\n";        # set output record separator
  56.  
  57. $TESTING = $FALSE;      # Should be FALSE when we ship
  58.  
  59. $INFO = 1;
  60. $START = 1;
  61. $PROCESS = 2;
  62. $END = 3;
  63.  
  64. $DEFAULT  = 1;
  65. $REQUIRED = 2;
  66. $OPTIONAL = 3;
  67.  
  68. $SIG{'INT'} = $SIG{'TERM'} = 'abort';
  69.  
  70. chop($workdir = `pwd`);
  71. die( "You don't have write permission in: $workdir\n" ) if ! -w $workdir;
  72.  
  73. # figure out the naming conventions on the CDROM
  74. $UPPER = 1;
  75. $REVISION = 2;
  76. $DOT = 4;
  77. $UPPERZ = 8;
  78. $NAMEFAULT = 16;
  79. for ($NAMING = 0 ; $NAMING < 16 ; $NAMING++) {
  80.    last if -f &iso9660("config1") &&
  81.            -f &iso9660("config2.rev") &&
  82.            -f &iso9660("config3.Z");
  83. }
  84. die "Can't determine CDROM naming conventions\n" if $NAMING >= $NAMEFAULT;
  85.  
  86. # start processing
  87. open(PAKS, &iso9660("COMMON/PACKAGES"));
  88.  
  89. local($PAKname);
  90. while (<PAKS>) {
  91.    undef @packages; $pak_cnt = 0;
  92.    chop;
  93.    $PAKname = $_;
  94.    while (<PAKS>) {
  95.       chop;
  96.       last if $_ eq '';
  97.       @field = split;
  98.       next if $field[1] eq 'S' && !$SourcePak;
  99.       next if $field[1] eq 'R' &&  $SourcePak;
  100.       next if $field[1] eq 'T' &&  $SourcePak;
  101.       $packages[$pak_cnt++] = $field[0];
  102.       $packages{$field[0]} = $TRUE;
  103.       $fullname{&standard($field[0])} = $field[0];
  104.    } 
  105.    next if defined(%pak) && !defined($pak{$PAKname});
  106. }
  107.  
  108. if (defined $packages{$ARGV[0]}) {
  109.    $buildtype = 'L.X';
  110.    $buildtype = 'U.X', $up = 'UPPER'
  111.                       if ($NAMING & $UPPER);
  112.    $buildtype .= 'D'  if ($NAMING & $DOT);
  113.    $buildtype .= 'Z'  if ($NAMING & $UPPERZ);
  114.    $buildtype .= 'R'  if ($NAMING & $REVISION);
  115.    $buildtype =~ s/X(\w)/$1/;
  116.  
  117.    exec( &iso9660s('SOURCES/'.&standard($ARGV[0])."/BUILD$buildtype") ." $MACHINE");
  118. }
  119.  
  120. printf( STDERR "\nBUILD is available for the following packages:\n\n" );
  121. for $p (sort keys %packages) {
  122.     $line = sprintf( "$line%-13s", $p );
  123.     printf("$line\n"), $line='', $cnt=0 if (++$cnt == 6);
  124. }
  125. printf "$line\n" if $cnt;
  126. printf "\n";
  127.  
  128. exit 0;
  129.  
  130. sub iso9660 {
  131.    local( $path ) = @_;
  132.    $path =~ s:($CDROM/|;1$)::g;
  133.    if ($NAMING & $UPPER) {
  134.        $path =~ tr/a-z+!\-/A-Z_/;
  135.    }
  136.    else {
  137.        $path =~ tr/A-Z+!\-/a-z_/;
  138.    }
  139.    if ($path !~ /\*$/) {
  140.       if ($NAMING & $DOT) {
  141.          $path .= '.' if $path !~ /(.*\/)?.*\./;
  142.       }
  143.       $path .= ';1' if $NAMING & $REVISION;
  144.    }
  145.    $path =~ s/\.z/\.Z/ if $NAMING & $UPPERZ;
  146.  
  147.    return "$CDROM/$path";
  148. }
  149.  
  150. sub iso9660s {
  151.    local( $path ) = @_;
  152.    ($path = &iso9660($path)) =~ s/;/\\;/g;
  153.    return $path;
  154. }
  155.  
  156. #
  157. # Subroutines
  158. #
  159.  
  160. sub abort {
  161.    local($reason) = @_;
  162.    warn("$reason\n");
  163.    exit 1;
  164. }
  165.  
  166.  
  167. sub standard {
  168.    local($name) = @_;
  169.    ($name = substr($name,0,8)) =~ tr/A-Z/a-z/;
  170.    return $name;
  171. }
  172.